using System.Collections.Generic;
using System;
using System.Security.Claims;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using System.Linq;
using Newtonsoft.Json;

using Read.Services;
using Read.Models;

namespace Read.Web.Admin
{
    /// <summary>
    /// 后台管理
    /// </summary>
    //[Authorize]
    public class HomeController : AdminBaseController
    {
        /// <summary>
        /// 后台首页 //throw new InvalidOperationException("You did something invalid.");
        /// </summary>
        /// <returns></returns>
        public IActionResult Index()
        {
            //var role = User.FindFirst(ClaimTypes.Role).Value;
            //var userData = User.FindFirst(ClaimTypes.UserData).Value;
            //var userName = User.Identity.Name;
            ViewBag.userName = IdentityName;
            //return Json(new { Role = role, UserName = userName });
            //var menu = new NodeServices();
            //var menulist = menu.getMenu(role);  //JsonConvert.SerializeObject(adminlist);
            //ViewBag.UserData = JsonConvert.SerializeObject(menulist);// + Connection.MySql;
            //return Json(JsonConvert.DeserializeObject<ApplicationUser>(userData));
            return View();
        }

        /// <summary>
        /// 默认欢迎页
        /// </summary>
        /// <returns></returns>
        public IActionResult Main()
        {
            return View();
        }

        //---------------以下都是调试信息忽略不用管----------------//
        /// <summary>
        /// Test3
        /// </summary>
        /// <returns></returns>
        public IActionResult Test3()
        {
            return Json("Test3");
        }
        /// <summary>
        /// Test2
        /// </summary>
        /// <returns></returns>
        public IActionResult Test2()
        {
            return Json("Test2");
        }

        /// <summary>
        /// Test
        /// </summary>
        /// <returns></returns>
        public IActionResult Test()
        {
            return Json("Test");
        }
    }
}